#include <bits/stdc++.h>
using namespace std;
#define int long long

int arr[1000010] = {};
int nows[1000010] = {};
int pre = -1;
int cnt = 0;

signed main() {
    int n = 0,q = 0;
    cin >> n >> q;
    for(int i = 0;i < n; ++ i) {
        cin >> arr[i];
    }
    for(int i = 0;i < q; ++ i) {
        int k1,k2;
        cin >> k1 >> k2;
        if(k2 != pre) {
            cnt = 0;
            for(int j = 0;j < n; ++ j) {
                if(arr[j] > k2) 
                    nows[cnt++] = arr[j];
            }
            pre = k2;
        }
        if(k1 > cnt || k1 <= 0) cout << "?" << endl;
        else cout << nows[k1-1] << endl;
    }
    return 0;
}